﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TDNA
{
    public struct tdVector2
    {
        public double X { get; set; }
        public double Y { get; set; }
        public static tdVector2 One { get { return new tdVector2(1, 1); } }

        public tdVector2(double x, double y)
            : this()
        {
            X = x;
            Y = y;
        }

        public static float Dist(tdVector2 a, tdVector2 b)
        {
            return (float) Math.Sqrt((Math.Pow((float)(a.X - b.X), 2) + Math.Pow((float)(a.Y - b.Y), 2)));
        }

        public static double Length(tdVector2 a)
        {
            return Math.Sqrt(Math.Pow((double)a.X, 2) + Math.Pow((double)a.Y, 2));
        }

        public static bool Equals(tdVector2 a, tdVector2 b)
        {
            return ((a.X == b.X) && (a.Y == b.Y)); 
        }

        public static tdVector2 Normalize(tdVector2 a)
        {
            double l = tdVector2.Length(a);
            return new tdVector2(a.X / l, a.Y / l);
        }

        public static tdVector2 operator -(tdVector2 c1, tdVector2 c2)
        {
            return new tdVector2(c1.X - c2.X, c1.Y - c2.Y);
        }
        public static tdVector2 operator +(tdVector2 c1, tdVector2 c2)
        {
            return new tdVector2(c1.X + c2.X, c1.Y + c2.Y);
        }

        public static tdVector2 operator *(tdVector2 c1, float c2)
        {
            return new tdVector2(c1.X *c2, c1.Y *c2);
        }

        public static tdVector2 operator *(float c2, tdVector2 c1)
        {
            return new tdVector2(c1.X * c2, c1.Y * c2);
        }



    }
}
